<?php
class Default_Model_DbTable_Inclusion extends Zend_Db_Table_Abstract
{
	 protected $_name = 'hae_bdd_inclusions';
	 protected $_sequence=true;
     protected $_primary='id';
	public function getinclusion($id)
	{
	    $id = (int)$id;
	    $row = $this->fetchRow('id=' . $id);
		if(!$row)
		{ 
			throw  new Exception("Could not find row {$id}");
			return 0;
		}
		return $row->toArray();
	}
	public function getlistinclusion($inclusion)
	{
	    //Locale
	    $locale = new HAE_Element_Locale();
	    $lang = $locale->getLocale();
	    
		$list_inclusion = explode("_", $inclusion);
		$str = "";
		for ($i=0;$i<count($list_inclusion)-2;$i++ )
		{
				$str.= "id = ".$list_inclusion[$i]." OR ";
		}
		$str.="id = ".$list_inclusion[count($list_inclusion)-2];
		
		$select = $this->select();
		$select->from($this->_name,array('id','title_'.$lang.' AS title'));
		$select->where($str);
		
		return $this->fetchAll($select);
	}
}
?>